- 
        Couldn't load subscription status. 
- Fork 305
chore(lazer) Added Feed struct #3135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub. 
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing logic LGTM! Would be great to see some positive and negative tests
| function hasPrice( | ||
| PythLazerStructs.Feed memory feed | ||
| ) public pure returns (bool) { | ||
| return (feed.existsFlags & PythLazerStructs.PRICE_EXISTS) != 0; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create getters for the properties that enforce checking existence? It would ensure users dont assume a property like price always exists. Something like getPrice(feed) -> (bool, int64), it could return (exists, value). It's an alternative to storing the type as Option<Option<PropertyType>>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are chances that user can ignore the exist flag. Plus returning a bool will consume more gas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands they would have to first call hasPrice before using the price, which to me sounds like a greater chance of being missed by implementors since they would have to know about that method and intentionally use it. On the other hand, the exists flag more clearly signals the possibility that the field may not exist, and one would have to acknowledge this to ignore it. But that's just my opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can just call getPrice(). It will return an error if price is zero.
Summary
Rationale
How has this been tested?